#include <iostream>
using namespace std;

int main() {
    int result = 0;
    string curr, target;
    cin >> curr >> target;
    for (int i = 0; i < curr.size(); i++) {
        int sub = target[i] - curr[i];
        if (sub < 0) {
            if (target[i] >= 'A' && target[i] <= 'Z') { sub += 26; }
            if (target[i] >= '0' && target[i] <= '9') { sub += 10; }
        }
        result += sub;
    }
    cout << result;
    return 0;
}